<?php

namespace App\Modules\Admin\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

/**
 * Class AdminUser
 * *
 * @property $admin_uid  管理员ID
 * @property $account  帐号
 * @property $password  密码
 * @property $name  管理员名称
 * @property $avatar  管理员头像
 * @property $sex  性别 0: 无 1: 男 2: 女
 * @property $source_type  来源类型 0: 系统 1: 后台
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
 *
 * @package  App\Modules\Admin\Models
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
class AdminUser extends Authenticatable implements JWTSubject
{
    use SoftDeletes;

    public $incrementing = false;

    protected $table = 'admin_users';
    protected $primaryKey = 'admin_uid';
    protected $hidden = [
        'password',
    ];

    protected $fillable = ['admin_uid', 'account', 'password', 'name', 'avatar', 'sex', 'source_type'];

    public function adminRoleUser()
    {
        return $this->hasMany(AdminRoleUser::class, 'admin_uid', 'admin_uid')->select('role_uid', 'admin_uid');
    }

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }
}
